from tkinter import *


class UiHelper(object):

    def __init__(self, window):
        self.window = window

    def center_window(self, width, height):
        screen_width = self.window.winfo_screenwidth()
        screen_height = self.window.winfo_screenheight()
        x = (screen_width // 2) - (width // 2)
        y = (screen_height // 2) - (height // 2)
        self.window.geometry(f"{width}x{height}+{x}+{y}")

    def close_window(self):
        self.window.destroy()


class Chk(object):



    def __init__(self, window):
        self.window = window
        self.check_values = IntVar()

    def create_checkbutton_label_group(self, row, col, label_name, items):
        check_values = []
        group_label = Label(self.window, text=label_name)
        group_label.configure(bg="white")
        group_label.grid(row=row, column=0)
        # add vars
        for i in range(len(items)):
            check_values.append(IntVar())

        for key, value in items.items():
            chk = Checkbutton(self.window, text=key, onvalue=value, variable=check_values[list(items.keys()).index(key)])
            chk.configure(bg="white")
            chk.grid(row=row, column=col)
            col += 1
        return check_values

    def create_input_label_group(self, row, col, label_name):
        input_label = Label(self.window, text=label_name)
        input_label.grid(row=row, column=0)
        input_label.configure(bg="white")
        entry = Entry(self.window)
        entry.grid(row=row, column=col)
        return entry
